{% extends 'TopxiaWebBundle::layout.html.twig' %}


{% block title %}签到记录  - {{ parent() }}{% endblock %}

{% block keywords %}{{ user.title }}{% endblock %}
{% block description %}{{ user.about|default('')|plain_text(100) }}{% endblock %}
{% set bodyClass = 'userpage' %}
{% set pageNav = pageNav|default(null) %}

{% set script_controller = 'user/user' %}

{% block content %}

{{ render(controller('TopxiaWebBundle:User:headerBlock', {user:user})) }}

{% block main %}
<style>
.rilizhanshi{ width:100%;background-image: url(/img/qiandaobg.png); background-repeat: no-repeat;background-size:100% 100%;padding-top:140px;padding-bottom:20px;}
#rilitable{ width:80%; margin:0 auto; }
#rilitable tr td{  
    line-height: 90px;
	width:14%;	
    font-size: 36px;
    font-weight: bold;    
    text-align: center;
    color: #c56500;border-radius:20px; background:#ffffef;border:1px solid #ffbd63;
padding-bottom:0px;
	}
#rilitable tr td.qd_td_bg{ background:#ff6b5a;}
#rilitable tr td input{border:none; background:none; color:#fff; font-family: "Microsoft YaHei";}
@media screen and (max-width: 639px){
.rilizhanshi{ width:100%;background-image: url(/img/qiandaobg.png); background-repeat: no-repeat;background-size:100% 100%;padding-top:70px;padding-bottom:20px;}
#rilitable tr td{  
    line-height: 45px;
	width:14%;	
    font-size: 18px;
    font-weight: bold;    
    text-align: center;
    color: #c56500;border-radius:10px; background:#ffffef;border:1px solid #ffbd63;
padding-bottom:0px;
	}
}
</style>
<div >
	<div><h2><font color="red">当前总积分：</font>{{ userintegral }}</h2></div>
<div class="rilizhanshi">
<table id = "rilitable" ></table>
</div>

 <script>
     var firstweek = {{ firstweek }};
     var lastday = {{ lastday }};
     var i = 0,h=0,l=0;
     var obj = document.getElementById('rilitable');
     var html = "";
     for(i=1;i<=lastday;i++){
         if (l==0)
            html += "<tr>";
         if (h==0 && l<firstweek){
             html += "<td></td>";
             l++;
             i--;
             continue;
         }
         html += '<td id = "day'+ i +'">'+"<span>"+i+"</span>"+'</td>';
         l++;
         if(l== 7){
             l=0;
             h++;
             html+='</tr>';
         }
         
     }
     obj.innerHTML=html;
     
     
     
     var integrarr = [];
     var i = 0;
     {%for v in integrarr%}

		 integrarr[i]=[];
		 integrarr[i]['signintime']= parseInt('{{ v.signintime }}',10);
		 //integrarr[i]['signinintegral']= '{{ v.signinintegral }}';
		 i++;
     {%endfor%}
     
     var thisday = new Date().getDate();
     
     var isqd = false;
     for (var i =0;i<integrarr.length;i++){
         var obj = document.getElementById("day"+integrarr[i]['signintime']);
         obj.innerHTML = "√";
         if (integrarr[i]['signintime'] == thisday)
             isqd=true;
     }
      if(!isqd){
		document.getElementById("day"+thisday).className="qd_td_bg";
        document.getElementById("day"+thisday).innerHTML="<input type='button' onclick='qd();' id='qd' value='签到' />";
      }else
        document.getElementById("day"+thisday).innerHTML="√";
     
      
</script>
<script>
    function qd(){
       
       var userid='{{ userid }}';
       var url="{{path('user_qdsignin')}}";
       var thisday = new Date().getDate();
           $.ajax({
                url : url,
                data : {"userid":userid},
                type : "post",
                dataType : 'json',
                success : function(data) {
                  if(data.name=='0'){
                      alert('已签到');
                  }else if(data.name=='1'){
                      //alert('签到成功');
					  location.reload(true);
                      document.getElementById("day"+thisday).innerHTML="√";
                      document.getElementById("day"+thisday).setAttribute("class", "");
                     var ab=document.getElementById("qd");
                      ab.style.display="none";
                       
                  }else if(data.name=='2'){
                      alert('签到成功,恭喜您升级为VIP'+data.dj);
                      document.getElementById("day"+thisday).innerHTML="√";
                      document.getElementById("day"+thisday).setAttribute("class", "");
                     var ab=document.getElementById("qd");
                      ab.style.display="none";
                       
                  }
                },
          })  
      
    }

</script>
</div>


{% endblock %}
{% endblock %}